<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>9090分销管理平台</title>
    <jsp:include page="${pageContext.request.contextPath}/include/include.jsp"></jsp:include>
</head>
<body>
<div id="container" class="cls-container">

    <!-- BACKGROUND IMAGE -->
    <!--===================================================-->
    <div id="bg-overlay" class="bg-img"
         style="background-image: url(${pageContext.request.contextPath}/common/img/bg-img/bg-img-oa.jpg)"></div>
    <!-- LOGIN FORM -->
    <!--===================================================-->
    <div class="cls-content">
        <div class="cls-content-sm panel">
            <div class="panel-body">
                <div class="mar-ver pad-btm">
                    <h3 class="h4 mar-no">登录</h3>
                    <p class="text-muted">使用您的帐号密码进行登录</p>
                </div>
                <form id="loginForm" action="${pageContext.request.contextPath}/sysUser/login">
                    <div class="form-group">
                        <input type="text" id="fl_login_name" name="fl_login_name" class="form-control" placeholder="用户名" autofocus>
                    </div>
                    <div class="form-group">
                        <input type="password" id="fl_login_pwd" name="fl_login_pwd" class="form-control" placeholder="密码">
                    </div>
                    <div class="checkbox pad-btm text-left">
                        <input type="text" id="imgCode" name="imgCode" class="form-control" placeholder="验证码"
                               style="float: left;width: 162px;margin-right: 40px;">
                        <img alt="验证码出错啦~!" src="${pageContext.request.contextPath}/sysUser/img"
                             style="cursor: pointer;" title="更换验证码"
                             onclick="this.src='${pageContext.request.contextPath}/sysUser/img?q='+Math.random()"/>
                    </div>
                    <div class="checkbox pad-btm text-left">
                        <input id="demo-form-checkbox" class="magic-checkbox" type="checkbox">
                        <label for="demo-form-checkbox">记住我</label>
                    </div>
                    <button id="loginBtn" class="btn btn-primary btn-lg btn-block" type="button" onclick="login()">登&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;录
                    </button>
                </form>
            </div>

            <div class="pad-all">
                <a href="#" class="btn-link mar-rgt">忘记密码 ?</a>
                <a href="#" class="btn-link mar-lft">注册新账号</a>

                <div class="media pad-top bord-top">
                    <div class="pull-right">
                        <a href="#" class="pad-rgt"><i class="ti-facebook icon-lg text-primary"></i></a>
                        <a href="#" class="pad-rgt"><i class="ti-twitter-alt icon-lg text-info"></i></a>
                        <a href="#" class="pad-rgt"><i class="ti-google icon-lg text-danger"></i></a>
                    </div>
                    <div class="media-body text-left">
                        其他方式登陆
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--===================================================-->
</div>
<!--===================================================-->
<!-- END OF CONTAINER -->
<script>
    function login() {
        var imgCode = $("#imgCode").val();
        var name = $("#fl_login_name").val();
        var pwd = $("#fl_login_pwd").val();
        if (name === "" || name === null) {
            layer.msg("请输入登录账号");
            return;
        }
        if (pwd === "" || pwd === null) {
            layer.msg("请输入登录密码");
            return;
        }
        if (imgCode === "" || imgCode === null) {
            layer.msg("请输入验证码");
            return;
        }
        var url = "${pageContext.request.contextPath}/sysUser/login";
        var data = $("#loginForm").serialize();
        $.ajax({
            type: 'post',
            url: url,
            cache: false,
            data: data,
            dataType: 'json',
            success: function (data) {
                if (data.code === 0) {
                    window.location.href = "${pageContext.request.contextPath}/sysUser/index"
                } else {
                    $("#imgCode").click();
                    layer.msg(data.msg);
                }
            },
            error: function () {
                layer.msg('服务器繁忙');
            }
        });
    }
    $(function () {
        $(function () {
            //回车提交事件
            $("body").keydown(function() {
                if (event.keyCode == "13") {//keyCode=13是回车键
                    login();
                }
            });
        });
    });
</script>
</body>
</html>


